﻿using System.Windows.Forms;
using AMatysiak.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace AMatysiakTest.Controls
{
    [TestClass]
    public class DataGridViewEnumColumnTest
    {
        private enum Colors
        {
            BLACK,
            WHITE,
            BLUE
        }

        [TestMethod]
        public void createColumn()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewEnumColumn());
            Type type = grid.Columns[0].GetType();

            Assert.AreEqual(typeof(DataGridViewEnumColumn), type);
        }

        [TestMethod]
        public void createCell()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewEnumColumn());
            grid.Rows.Add(Colors.BLACK);
            Type type = grid.Rows[0].Cells[0].GetType();

            Assert.AreEqual(typeof(DataGridViewEnumCell), type);
        }

        [TestMethod]
        public void addCell()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewEnumColumn());
            grid.Rows.Add(Colors.BLACK);
            Colors color = (Colors)grid.Rows[0].Cells[0].Value;

            Assert.AreEqual(Colors.BLACK, color);
        }

        [TestMethod]
        public void changeCell()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewEnumColumn());
            grid.Rows.Add(Colors.BLACK);
            grid.Rows[0].Cells[0].Value = Colors.BLUE;
            Colors color = (Colors)grid.Rows[0].Cells[0].Value;

            Assert.AreEqual(Colors.BLUE, color);
        }
    }
}
